﻿using System;
using System.Drawing;
using MUnit;

namespace Maze
{
    class TestMovement
    {
        private SQ[,] squares = {{ SQ.W, SQ.O, SQ.W },
                                 { SQ.O, SQ.O, SQ.O },
                                 { SQ.W, SQ.O, SQ.W }};
        private Board board;
        private PathFinder pathFinder;
        private Player player;

        private Point startSquare = new Point(0, 1);

        [Setup]
        void Setup()
        {
            // This will be run once before each test method
            this.board = new Board(this.squares);
            this.pathFinder = new PathFinder(this.board);
            this.player = new Player(this.startSquare, this.pathFinder);
        }

        [Test]
        void GoBackToSquareWhenHalfway()
        {
            this.player.GoToSquare(new Point(2, 1));
            this.player.Update(2, this.board);
            this.player.GoToSquare(this.startSquare);
            this.player.Update(2, this.board);

            Verify.Equals(MazeForm.SquareToPixels(this.startSquare), this.player.Location);
        }

        [Test]
        void GoToAnotherSquareWhenHalfway()
        {
            this.player.GoToSquare(new Point(2, 1));
            this.player.Update(2, this.board);
            this.player.GoToSquare(new Point(1, 0));
            this.player.Update(2, this.board);
            this.player.Update(1, this.board);

            Verify.Equals(MazeForm.SquareToPixels(new Point(1, 0)), this.player.Location);
        }

        [Test]
        void EachGoToCostsOnePoint()
        {
            this.player.GoToSquare(new Point(2, 1));

            Verify.Equals(Player.StartScore - Player.MovementCost, this.player.Score);
        }

        [TearDown]
        void TearDown()
        {
            // This will be run once after each test method
        }
    }
}
